//
// MainViewController.m
// LBXDownLoad
//
// Created by lbxia on 2021/4/20
//
//
    

#import "MainViewController.h"
#import "LBXDownLoadManager.h"
#import <Sandboxer.h>
#import "FileDownListViewController.h"

@interface MainViewController ()<LBXDownLoadManagerProtocol>

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
}

- (IBAction)sandBoxAction:(id)sender {

    [Sandboxer shared].fileDeletable = YES;
    [Sandboxer shared].directoryDeletable = YES;
//    [Sandboxer shared].homeFileURL = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"tmp"]];
    [[Sandboxer shared] trigger];
}

- (IBAction)startTest:(id)sender {
    
    FileDownListViewController *vc = [FileDownListViewController new];
    [self.navigationController pushViewController:vc animated:YES];
    
    return;
    
    LBXDownLoadItem *item = [[LBXDownLoadItem alloc]init];
    item.remoteURL = @"https://www.imagomat.de/testimages/1.tiff";
    item.fileSize = 1024;
    
    
    item.remoteURL = @"https://www.apple.com/105/media/cn/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-cn-20170912_1280x720h.mp4";
    
    
    item.remoteURL = @"https://www.apple.com/105/media/us/iphone-12/2020/7f5b7de7-9f8c-41eb-bf3b-f294773108e6/films/product/iphone-12-product-tpl-us-2020_16x9.m3u8";
    
//https://www.apple.com.cn/imac-24/images/overview/colors_hero_fallback__co1mroy32piu_large.jpg
    
    //https://www.apple.com.cn/105/media/cn/iphone-12-pro/2020/e70ffbd8-50f1-40f3-ac36-0f03a15ac314/films/product/iphone-12-pro-product-tpl-cn-2020_16x9.m3u8
    
    //https://www.apple.com.cn/105/media/us/ipad-pro/2021/08087f4b-7539-4b1e-ae8a-adc18f4242ae/anim/cameras/large.mp4
    
        
//    [[LBXDownLoadManager sharedManager]addItem:item];
    
    [LBXDownLoadManager sharedManager].delegate = self;
    
    [[LBXDownLoadManager sharedManager]startWithItem:item];
    
//    [[LBXDownLoadManager sharedManager]storeItems];
//    [[LBXDownLoadManager sharedManager]loadItems];
}

//状态变化
- (void)LBXDownLoadStatus:(LBXDownLoadItem*)item
{
    NSLog(@"LBXDownLoadStatus：%ld",item.status);
}

//进度
- (void)LBXDownLoadProgress:(LBXDownLoadItem*)item
{
    NSLog(@"LBXDownLoadProgress:%lld,%lld",item.fileSize,item.downSize);
}

//硬盘空间不足，所有下载暂停
- (void)LBXDownLoadDiskSpaceNotAvailable
{
    
}


@end
